//
//  MultiCustomSegmentView.m
//  
//
//  Created by ET|冰琳 on 16/5/27.
//  Copyright © 2016年 . All rights reserved.
//

#import "MultiCustomSegmentView.h"
#import "TransformButton.h"

@implementation MultiCustomSegmentView

+ (instancetype)segmentViewWithTitles:(NSArray *)titles andFrame:(CGRect)frame{
    
    NSMutableArray *btns = [NSMutableArray arrayWithCapacity:titles.count];
    for (NSString *title in titles) {
        ArrowButton *arrow = [[ArrowButton alloc] initWithTitle:title ArrowImage:[UIImage imageNamed:@"arrow_icon"]];
        arrow.titleLabel.font = [UIFont systemFontOfSize:14.0];
        [arrow setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [arrow setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
        [btns addObject:arrow];
    }
    
    CGRect fSeg = frame;
    fSeg.origin.y = 0;
    
    UIButton *btn2 = [btns objectAtIndex:1];
    btn2.frame = ({
        CGRect f = btn2.frame;
        f.size.height = 100;
        f;
    });
    
    BIMultiSegmentControl *multi = [[EqualWSegmentControl alloc] initWithFrame:fSeg segmentItems:btns];
    multi.bottomlineView.hidden = NO;
    multi.backgroundColor = [UIColor whiteColor];
    
    [multi addVerticalLinesWithSize:[NSValue valueWithCGSize:CGSizeMake(0.5, 18)] color:nil];
    
    MultiCustomSegmentView * container = [[MultiCustomSegmentView alloc] initWithSegmentControl:multi];
    container.frame = frame;
    container.changeSegmentTitleWhenSelectRow = true;
    return container;
}
+ (instancetype)segmentViewWithTitles:(NSArray *)titles{
   return [self segmentViewWithTitles:titles andFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
}

@end
